# -------------------------------------------------------------
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#
# -------------------------------------------------------------

# Autogenerated By   : src/main/python/generator/generator.py
# Autogenerated From : scripts/builtin/img_mirror_linearized.dml

from typing import Dict, Iterable

from systemds.operator import OperationNode, Matrix, Frame, List, MultiReturn, Scalar
from systemds.utils.consts import VALID_INPUT_TYPES


def img_mirror_linearized(img_matrix: Matrix,
                          horizontal_axis: bool,
                          original_rows: int,
                          original_cols: int):
    """
     This function has  the same functionality with img_mirror but it handles multiple images at
     the same time. Each row of the input and output matrix represents a linearized image/matrix
     It flips an image on the X (horizontal) or Y (vertical) axis.
    
     .. code-block:: python
    
       >>> import numpy as np
       >>> from systemds.context import SystemDSContext
       >>> from systemds.operator.algorithm import img_mirror_linearized
       >>> 
       >>> with SystemDSContext() as sds:
       ...     img = sds.from_numpy(
       ...         np.array([[ 10., 20., 30.,
       ...                     40., 50., 60.,
       ...                     70., 80., 90. ]], dtype=np.float32)
       ...     )
       ...     result_img = img_mirror_linearized(img, True, 3, 3).compute()
       ...     print(result_img.reshape(3, 3))
       [[70. 80. 90.]
        [40. 50. 60.]
        [10. 20. 30.]]
    
    
     .. code-block:: python
    
       >>> import numpy as np
       >>> from systemds.context import SystemDSContext
       >>> from systemds.operator.algorithm import img_mirror_linearized
       >>> 
       >>> with SystemDSContext() as sds:
       ...     imgs = sds.from_numpy(
       ...         np.array([[ 10., 20., 30.,
       ...                     40., 50., 60.,
       ...                     70., 80., 90. ],
       ...                   [ 70., 80., 90.,
       ...                     40., 50., 60.,
       ...                     10., 20., 30. ]], dtype=np.float32)
       ...     )
       ...     result_imgs = img_mirror_linearized(imgs, True, 3, 3).compute()
       ...     print(result_imgs[0].reshape(3, 3))
       ...     print(result_imgs[1].reshape(3, 3))
       [[70. 80. 90.]
        [40. 50. 60.]
        [10. 20. 30.]]
       [[10. 20. 30.]
        [40. 50. 60.]
        [70. 80. 90.]]
    
    
    
    
    :param img_matrix: Input images as linearized 2D matrix with top left corner at [1, 1] (every row represents a linearized matrix/image)
    :param horizontal_axis: flip either in X or Y axis
    :param original_rows: number of rows in the original 2-D images
    :param original_cols: number of cols in the original 2-D images
    :return: Output matrix/image  (every row represents a linearized matrix/image)
    """

    params_dict = {'img_matrix': img_matrix, 'horizontal_axis': horizontal_axis, 'original_rows': original_rows, 'original_cols': original_cols}
    return Matrix(img_matrix.sds_context,
        'img_mirror_linearized',
        named_input_nodes=params_dict)
